<template>
  <div>
    <!-- 面包屑导航栏 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>活动管理</el-breadcrumb-item>
      <el-breadcrumb-item>活动列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片 包裹列表内容 -->
    <el-card class="box-card">
      <!-- 布局容器 -->
      <el-row :gutter="20">
        <!-- 搜索栏 -->
        <search @funQuery="search1"></search>
      </el-row>
      <!-- 表格  存放用户列表 -->
      <el-table :data="ordersList" style="width: 100%" stripe border>
        <el-table-column type="index"></el-table-column>
        <el-table-column prop="order_number" label="订单编号"></el-table-column>
        <el-table-column prop="order_price" label="订单价格"></el-table-column>
        <el-table-column label="是否付款">
          <template slot-scope="scope">
            <el-tag type="danger" v-if="scope.row.order_pay == '0'">未付款</el-tag>
            <el-tag type="danger" v-else>已付款</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="is_send" label="是否发货"></el-table-column>
        <el-table-column prop="create_time" label="下单时间"></el-table-column>
        <el-table-column label="操作">
          <template>
            <el-row>
              <el-button
                type="primary"
                icon="el-icon-edit"
                circle
                size="mini"
                @click="dialogVisible = true"
              ></el-button>
              <el-button
                type="warning"
                icon="el-icon-s-tools"
                circle
                size="mini"
                @click="addrOrders"
              ></el-button>
            </el-row>
          </template>
        </el-table-column>
      </el-table>
      <!-- 点击修改按钮弹出对话框 -->
      <el-dialog title="修改地址" :visible.sync="dialogVisible" width="70%" @close="addDialogClosed">
        <!-- 添加的内容 -->
        <el-form :model="addOrders" ref="addOrdersRef" label-width="100px" class="demo-ruleForm">
          <el-form-item label="省市区/县">
            <!-- 级联选择器 -->
            <el-cascader
              v-model="addOrders.address1"
              :options="cityData"
              :props="{ expandTrigger: 'hover' }"
              @change="handleChange"
            ></el-cascader>
          </el-form-item>
          <el-form-item label="详细地址" prop="address2">
            <el-input v-model="addOrders.address2"></el-input>
          </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button @click="dialogVisible = false">取 消</el-button>
          <el-button type="primary">确 定</el-button>
        </span>
      </el-dialog>
      <!-- 点击修改按钮弹出对话框 -->
      <el-dialog title="快递参数" :visible.sync="dialogVisible2" width="70%">
        <!-- 添加的内容 -->
        <el-timeline :reverse="reverse">
          <el-timeline-item
            v-for="(item, index) in addrOrdersList"
            :key="index"
            :timestamp="item.ftime"
          >{{item.context}}</el-timeline-item>
        </el-timeline>
        <span slot="footer" class="dialog-footer">
          <el-button @click="dialogVisible2 = false">取 消</el-button>
          <el-button type="primary">确 定</el-button>
        </span>
      </el-dialog>
    </el-card>
    <date1 :total="total" @funcF="show" @funcF2="show2"></date1>
  </div>
</template>
           
<script>
import cityData from "./citydata.js";
import date1 from "@/components/common/date.vue";
import search from "@/components/common/search.vue";
import { OrdersList_api, addrOrdersList_api } from "@/api";
export default {
  data() {
    return {
      ordersParams: {
        query: "",
        pagenum: 1,
        pagesize: 1
      },
      total: 0,
      ordersList: [],
      addOrders: {
        address1: [],
        address2: ""
      },
      reverse: true,
      addrOrdersList: [],
      cityData,
      dialogVisible: false,
      dialogVisible2: false
    };
  },
  methods: {
    async getOrders() {
      var { data: res } = await OrdersList_api(this.ordersParams);
      if (res.meta.status !== 200) {
        return this.$message.error("获取列表失败！");
      }
      console.log(res);
      this.total = res.data.total;
      this.ordersList = res.data.goods;
    },
    //分页功能
    show(val) {
      this.ordersParams.pagesize = val;
      this.getOrders();
    },
    show2(val) {
      this.ordersParams.pagenum = val;
      this.getOrders();
    },
    search1(val) {
      // console.log(val, 89);
      this.ordersParams.query = val;
      this.getOrders();
      console.log(this.ordersParams);
    },
    handleChange(value) {
      // console.log(value, 8989);
      // console.log(this.addOrders);
    },
    //点击添加关闭按钮
    addDialogClosed() {
      this.$refs.addOrdersRef.resetFields();
    },
    async addrOrders() {
      var { data: res } = await addrOrdersList_api("1106975712662");
        console.log(res, 77);
      // if (res.meta.stauts !== 200) {
      //  return this.$message.error("获取失败!");
      // }
      this.addrOrdersList = res.data;
      this.dialogVisible2 = true;
    }
  },
  created() {
    this.getOrders();
  },
  components: {
    date1,
    search
  }
};
</script>
<style scoped>
</style>